{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 2]\n",
      "[ 1.          2.71828183  7.3890561 ]\n",
      "[ 0.          1.          1.41421356]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "B = np.arange(3)\n",
    "print (B)\n",
    "print (np.exp(B))\n",
    "print (np.sqrt(B))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 6.  7.  2.  9.]\n",
      " [ 6.  0.  5.  2.]\n",
      " [ 9.  0.  9.  6.]]\n",
      "--------\n",
      "[ 6.  7.  2.  9.  6.  0.  5.  2.  9.  0.  9.  6.]\n",
      "--------\n",
      "[[ 6.  7.]\n",
      " [ 2.  9.]\n",
      " [ 6.  0.]\n",
      " [ 5.  2.]\n",
      " [ 9.  0.]\n",
      " [ 9.  6.]]\n",
      "--------\n",
      "[[ 6.  2.  6.  5.  9.  9.]\n",
      " [ 7.  9.  0.  2.  0.  6.]]\n"
     ]
    }
   ],
   "source": [
    "#Return the floor of the input\n",
    "a = np.floor(10*np.random.random((3,4)))\n",
    "print (a)\n",
    "print ('--------')\n",
    "#a.shape\n",
    "## flatten the array\n",
    "print (a.ravel())\n",
    "print ('--------')\n",
    "a.shape = (6, 2)\n",
    "print (a) \n",
    "print ('--------')\n",
    "print (a.T)\n",
    "\n",
    "\n",
    "#If a dimension is given as -1 in a reshaping operation, the other dimensions are automatically calculated:\n",
    "#a.reshape(3,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 3.  7.]\n",
      " [ 2.  6.]]\n",
      "---\n",
      "[[ 9.  6.]\n",
      " [ 0.  7.]]\n",
      "---\n",
      "[[ 3.  7.]\n",
      " [ 2.  6.]\n",
      " [ 9.  6.]\n",
      " [ 0.  7.]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = np.floor(10*np.random.random((2,2)))\n",
    "b = np.floor(10*np.random.random((2,2)))\n",
    "print (a)\n",
    "print ('---')\n",
    "print (b)\n",
    "print ('---')\n",
    "print (np.vstack((a,b)))\n",
    "#np.hstack((a,b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 8.  3.  3.  5.  9.  0.  1.  1.  6.  2.  7.  2.]\n",
      " [ 7.  1.  9.  7.  5.  2.  5.  7.  0.  3.  1.  1.]]\n",
      "---\n",
      "[array([[ 8.,  3.,  3.,  5.],\n",
      "       [ 7.,  1.,  9.,  7.]]), array([[ 9.,  0.,  1.,  1.],\n",
      "       [ 5.,  2.,  5.,  7.]]), array([[ 6.,  2.,  7.,  2.],\n",
      "       [ 0.,  3.,  1.,  1.]])]\n",
      "---\n",
      "[array([[ 8.,  3.,  3.],\n",
      "       [ 7.,  1.,  9.]]), array([[ 5.],\n",
      "       [ 7.]]), array([[ 9.,  0.,  1.,  1.,  6.,  2.,  7.,  2.],\n",
      "       [ 5.,  2.,  5.,  7.,  0.,  3.,  1.,  1.]])]\n",
      "---\n",
      "[[ 8.  1.]\n",
      " [ 3.  2.]\n",
      " [ 8.  0.]\n",
      " [ 9.  0.]\n",
      " [ 9.  0.]\n",
      " [ 5.  3.]\n",
      " [ 3.  3.]\n",
      " [ 7.  2.]\n",
      " [ 5.  7.]\n",
      " [ 9.  6.]\n",
      " [ 4.  0.]\n",
      " [ 8.  4.]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[array([[ 8.,  1.],\n",
       "        [ 3.,  2.],\n",
       "        [ 8.,  0.],\n",
       "        [ 9.,  0.]]), array([[ 9.,  0.],\n",
       "        [ 5.,  3.],\n",
       "        [ 3.,  3.],\n",
       "        [ 7.,  2.]]), array([[ 5.,  7.],\n",
       "        [ 9.,  6.],\n",
       "        [ 4.,  0.],\n",
       "        [ 8.,  4.]])]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.floor(10*np.random.random((2,12)))\n",
    "print (a)\n",
    "print ('---')\n",
    "print (np.hsplit(a,3))\n",
    "print ('---')\n",
    "print (np.hsplit(a,(3,4)))   # Split a after the third and the fourth column\n",
    "a = np.floor(10*np.random.random((12,2)))\n",
    "print ('---')\n",
    "print (a)\n",
    "np.vsplit(a,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "(3, 4)\n",
      "1974659569504\n",
      "1974659569504\n"
     ]
    }
   ],
   "source": [
    "#Simple assignments make no copy of array objects or of their data.\n",
    "a = np.arange(12)\n",
    "b = a\n",
    "# a and b are two names for the same ndarray object\n",
    "print (b is a)\n",
    "b.shape = 3,4\n",
    "print (a.shape)\n",
    "print (id(a))\n",
    "print (id(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "(3, 4)\n",
      "[[   0    1    2    3]\n",
      " [1234    5    6    7]\n",
      " [   8    9   10   11]]\n",
      "1974659569504\n",
      "1974659621312\n"
     ]
    }
   ],
   "source": [
    "#The view method creates a new array object that looks at the same data.\n",
    "c = a.view()\n",
    "print (c is a)\n",
    "c.shape = 2,6\n",
    "print (a.shape)\n",
    "c[0,4] = 1234\n",
    "print (a)\n",
    "print (id(a))\n",
    "print (id(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[9999    1    2    3]\n",
      " [1234    5    6    7]\n",
      " [   8    9   10   11]]\n",
      "[[   0    1    2    3]\n",
      " [1234    5    6    7]\n",
      " [   8    9   10   11]]\n"
     ]
    }
   ],
   "source": [
    "#The copy method makes a complete copy of the array and its data.\n",
    "d = a.copy() \n",
    "d is a\n",
    "d[0,0] = 9999\n",
    "print (d) \n",
    "print (a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
